<?php $this->pageTitle = Yii::app()->name . ' - ' . UserModule::t("Profile");

?>
<div class='row'>

    <div class="col-md-3">
    </div>
    <div class="col-md-6">
        <h1><?php echo UserModule::t('Your profile'); ?></h1>

        <?php if (Yii::app()->user->hasFlash('profileMessage')): ?>
            <div class="success">
                <?php echo Yii::app()->user->getFlash('profileMessage'); ?>
            </div>
        <?php endif; ?>
        <table class="table table-hover">
            <tr>
                <td><?php echo CHtml::encode($model->getAttributeLabel('username')); ?></td>
                <td><?php echo CHtml::encode($model->username); ?></td>
            </tr>
            <?php
            $profileFields = ProfileField::model()->forOwner()->sort()->findAll();
            if ($profileFields) {
                foreach ($profileFields as $field) {
                    //echo "<pre>"; print_r($profile); die();
                    ?>
                    <tr>
                        <td><?php echo CHtml::encode(UserModule::t($field->title)); ?></td>
                        <td><?php echo(($field->widgetView($profile)) ? $field->widgetView($profile) : CHtml::encode((($field->range) ? Profile::range($field->range, $profile->getAttribute($field->varname)) : $profile->getAttribute($field->varname)))); ?></td>
                    </tr>
                <?php
                }
                //$profile->getAttribute($field->varname)
            }
            ?>
            <tr>
                <td><?php echo CHtml::encode($model->getAttributeLabel('email')); ?></td>
                <td><?php echo CHtml::encode($model->email); ?></td>
            </tr>
            <tr>
                <td><?php echo CHtml::encode($model->getAttributeLabel('create_at')); ?></td>
                <td><?php echo $model->create_at; ?></td>
            </tr>
            <tr>
                <td><?php echo CHtml::encode($model->getAttributeLabel('lastvisit_at')); ?></td>
                <td><?php echo $model->lastvisit_at; ?></td>
            </tr>
            <tr>
                <td><?php echo CHtml::encode($model->getAttributeLabel('status')); ?></td>
                <td><?php echo CHtml::encode(User::itemAlias("UserStatus", $model->status)); ?></td>
            </tr>
            <tr>
                <td></td>
                <td><?php echo CHtml::button('Edit', array('submit' => array('/user/profile/edit'), 'class' => 'btn btn-primary')); ?></td>
            </tr>
        </table>
    </div>
    <div class="col-md-3">
    </div>

</div>